//home模块的小仓库
import { reqCategoryList, reqGetBannerList } from '@/api';

export default {
    namespaced: true,
    state: {
        categoryList: [],
        bannerList: [],
    },
    actions: {
        async categoryList(state) {
            let result = await reqCategoryList()
            if(result.code == 200){
                state.commit("CATEGORYLIST", result.data)
            }
        },
        //获取首页轮播图的数据
        async getBannerList(state){
            let result = await reqGetBannerList()
            // console.log(result)
            if(result.code == 200){
                state.commit('GETBANNERLIST', result.data)
            }
        }
    },
    mutations: {
        CATEGORYLIST(state, categoryList){
            state.categoryList = categoryList
        },
        GETBANNERLIST(state, bannerList){
            state.bannerList = bannerList
        }
    },
    getters: {},
}